package utildate;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Scanner;

public class LocalTimeTest {
    public static void main(String[] args) {
        //请输入生日
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入生日：");
        String birthday = sc.next();

        //使用DateTimeFormatter控制格式
        DateTimeFormatter old = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        DateTimeFormatter newDate = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
        //将字符串转换成LocalTime对象
        try {
            LocalDate time = LocalDate.parse(birthday,old);
            System.out.println(LocalDate.parse(birthday,old));
            LocalDate time1 = time.plusMonths(1);
            System.out.println(time1.format(newDate));
        } catch (Exception e) {
            System.out.println("❌ 输入格式错误！请按照 yyyy-MM-dd 格式输入，比如：2000-01-01");
        }
    }
}
